LOCAL_PATH := $(call my-dir)
TOP:=$(LOCAL_PATH)/..
CPPUNIT_DIR := $(TOP)/test/cppunit/cppunit
TUTK_P4P_STATIC_LIBRARY :=
TUTK_P4P_SHARED_LIBRARY :=
TUTK_IOTC_SHARED_LIBRARY :=
TUTK_RDT_SHARED_LIBRARY :=
ifeq ($(strip $(TARGET_ARCH_ABI)),mips)
    TUTK_P4P_SHARED_LIBRARY :=$(TOP)/thirdparty/tutk/Android/$(TARGET_ARCH_ABI)/libp4p.so 
    TUTK_IOTC_SHARED_LIBRARY:=$(TOP)/thirdparty/tutk/Android/$(TARGET_ARCH_ABI)/libIOTCAPIs.so
    TUTK_RDT_SHARED_LIBRARY:=$(TOP)/thirdparty/tutk/Android/$(TARGET_ARCH_ABI)/libRDTAPIs.so
endif
ifeq ($(strip $(TARGET_ARCH_ABI)),armeabi)
    TUTK_P4P_SHARED_LIBRARY :=$(TOP)/thirdparty/tutk/Android/$(TARGET_ARCH_ABI)/libp4p.so 
    TUTK_IOTC_SHARED_LIBRARY :=$(TOP)/thirdparty/tutk/Android/$(TARGET_ARCH_ABI)/libIOTCAPIs.so
    TUTK_RDT_SHARED_LIBRARY :=$(TOP)/thirdparty/tutk/Android/$(TARGET_ARCH_ABI)/libRDTAPIs.so
endif
ifeq ($(strip $(TARGET_ARCH_ABI)),armeabi-v7a)
    TUTK_P4P_SHARED_LIBRARY :=$(TOP)/thirdparty/tutk/Android/$(TARGET_ARCH_ABI)/libp4p.so 
    TUTK_IOTC_SHARED_LIBRARY :=$(TOP)/thirdparty/tutk/Android/$(TARGET_ARCH_ABI)/libIOTCAPIs.so
    TUTK_RDT_SHARED_LIBRARY :=$(TOP)/thirdparty/tutk/Android/$(TARGET_ARCH_ABI)/libRDTAPIs.so
endif
ifeq ($(strip $(TARGET_ARCH_ABI)),x86)
    TUTK_P4P_SHARED_LIBRARY :=$(TOP)/thirdparty/tutk/Android/$(TARGET_ARCH_ABI)/libp4p.so 
    TUTK_IOTC_SHARED_LIBRARY :=$(TOP)/thirdparty/tutk/Android/$(TARGET_ARCH_ABI)/libIOTCAPIs.so
    TUTK_RDT_SHARED_LIBRARY :=$(TOP)/thirdparty/tutk/Android/$(TARGET_ARCH_ABI)/libRDTAPIs.so
endif

ifneq ($(TUTK_P4P_SHARED_LIBRARY),)
    include $(CLEAR_VARS)
    LOCAL_MODULE := p4p
    LOCAL_SRC_FILES := $(TUTK_P4P_SHARED_LIBRARY)
    LOCAL_EXPORT_C_INCLUDES := $(TARGET_ARCH_ABI)/include
    include $(PREBUILT_SHARED_LIBRARY) 
endif
ifneq ($(TUTK_IOTC_SHARED_LIBRARY),)
    include $(CLEAR_VARS)
    LOCAL_MODULE := iotc
    LOCAL_SRC_FILES := $(TUTK_IOTC_SHARED_LIBRARY)
    LOCAL_EXPORT_C_INCLUDES := $(TARGET_ARCH_ABI)/include
    include $(PREBUILT_SHARED_LIBRARY) 
endif
ifneq ($(TUTK_RDT_SHARED_LIBRARY),)
    include $(CLEAR_VARS)
    LOCAL_MODULE := rdt
    LOCAL_SRC_FILES := $(TUTK_RDT_SHARED_LIBRARY)
    LOCAL_EXPORT_C_INCLUDES := $(TARGET_ARCH_ABI)/include
    include $(PREBUILT_SHARED_LIBRARY) 
endif


include $(CLEAR_VARS)
LOCAL_C_INCLUDES := $(TOP)/include $(TOP)/source/include \
	$(TOP)/source/stdsdk \
	$(TOP)/source/stdsdk/include \
	$(TOP)/source/pullsdk \
	$(TOP)/source/pullsdk/include \
	$(TOP)/thirdparty/tutk/include \
	$(TOP)/source/plugin
	
LOCAL_MODULE    := udk
LOCAL_CPPFLAGS := -fsigned-char -fpermissive -DCOMM_MODULE_AUTOINSTALL=1
LOCAL_LDLIBS := -llog -landroid
#LOCAL_SHARED_LIBRARIES := p4p
#ifneq ($(TUTK_IOTC_SHARED_LIBRARY),)
#    LOCAL_SHARED_LIBRARIES+=iotc
#endif
#ifneq ($(TUTK_RDT_SHARED_LIBRARY),)
#    LOCAL_SHARED_LIBRARIES+=rdt
#endif

LOCAL_SRC_FILES := \
	$(wildcard $(TOP)/source/udk/*.cpp) \
	$(wildcard $(TOP)/source/pd/android/*.cpp) \
	$(wildcard $(TOP)/source/common/*.cpp) \
	$(wildcard $(TOP)/source/stdsdk/*.cpp) \
	$(wildcard $(TOP)/source/pullsdk/*.cpp)  \
	$(TOP)/source/plugin/commbt.cpp \
	$(TOP)/source/plugin/commtcp.cpp \
	$(TOP)/source/plugin/commudp.cpp \
	udk_jni.cpp
LOCAL_PRELINK_MODULE := false
LOCAL_ALLOW_UNDEFINED_SYMBOLS := false	
include $(BUILD_SHARED_LIBRARY)

# include cppunit code
#include $(CPPUNIT_DIR)/Android.mk
include $(CLEAR_VARS)
LOCAL_C_INCLUDES := \
	$(CPPUNIT_DIR)/include
LOCAL_MODULE := cppunit
LOCAL_CPP_FEATURES := rtti exceptions
LOCAL_SRC_FILES := \
	$(CPPUNIT_DIR)/src/cppunit/AdditionalMessage.cpp \
	$(CPPUNIT_DIR)/src/cppunit/Asserter.cpp \
	$(CPPUNIT_DIR)/src/cppunit/BeOsDynamicLibraryManager.cpp \
	$(CPPUNIT_DIR)/src/cppunit/BriefTestProgressListener.cpp \
	$(CPPUNIT_DIR)/src/cppunit/CompilerOutputter.cpp \
	$(CPPUNIT_DIR)/src/cppunit/DefaultProtector.cpp \
	$(CPPUNIT_DIR)/src/cppunit/DynamicLibraryManager.cpp \
	$(CPPUNIT_DIR)/src/cppunit/DynamicLibraryManagerException.cpp \
	$(CPPUNIT_DIR)/src/cppunit/Exception.cpp \
	$(CPPUNIT_DIR)/src/cppunit/Message.cpp \
	$(CPPUNIT_DIR)/src/cppunit/RepeatedTest.cpp \
	$(CPPUNIT_DIR)/src/cppunit/PlugInManager.cpp \
	$(CPPUNIT_DIR)/src/cppunit/PlugInParameters.cpp \
	$(CPPUNIT_DIR)/src/cppunit/Protector.cpp \
	$(CPPUNIT_DIR)/src/cppunit/ProtectorChain.cpp \
	$(CPPUNIT_DIR)/src/cppunit/SourceLine.cpp \
	$(CPPUNIT_DIR)/src/cppunit/StringTools.cpp \
	$(CPPUNIT_DIR)/src/cppunit/SynchronizedObject.cpp \
	$(CPPUNIT_DIR)/src/cppunit/Test.cpp \
	$(CPPUNIT_DIR)/src/cppunit/TestAssert.cpp \
	$(CPPUNIT_DIR)/src/cppunit/TestCase.cpp \
	$(CPPUNIT_DIR)/src/cppunit/TestCaseDecorator.cpp \
	$(CPPUNIT_DIR)/src/cppunit/TestComposite.cpp \
	$(CPPUNIT_DIR)/src/cppunit/TestDecorator.cpp \
	$(CPPUNIT_DIR)/src/cppunit/TestFactoryRegistry.cpp \
	$(CPPUNIT_DIR)/src/cppunit/TestFailure.cpp \
	$(CPPUNIT_DIR)/src/cppunit/TestLeaf.cpp \
	$(CPPUNIT_DIR)/src/cppunit/TestNamer.cpp \
	$(CPPUNIT_DIR)/src/cppunit/TestPath.cpp \
	$(CPPUNIT_DIR)/src/cppunit/TestPlugInDefaultImpl.cpp \
	$(CPPUNIT_DIR)/src/cppunit/TestResult.cpp \
	$(CPPUNIT_DIR)/src/cppunit/TestResultCollector.cpp \
	$(CPPUNIT_DIR)/src/cppunit/TestRunner.cpp \
	$(CPPUNIT_DIR)/src/cppunit/TestSetUp.cpp \
	$(CPPUNIT_DIR)/src/cppunit/TestSuccessListener.cpp \
	$(CPPUNIT_DIR)/src/cppunit/TestSuite.cpp \
	$(CPPUNIT_DIR)/src/cppunit/TestSuiteBuilderContext.cpp \
	$(CPPUNIT_DIR)/src/cppunit/TextOutputter.cpp \
	$(CPPUNIT_DIR)/src/cppunit/TextTestProgressListener.cpp \
	$(CPPUNIT_DIR)/src/cppunit/TextTestResult.cpp \
	$(CPPUNIT_DIR)/src/cppunit/TextTestRunner.cpp \
	$(CPPUNIT_DIR)/src/cppunit/TypeInfoHelper.cpp \
	$(CPPUNIT_DIR)/src/cppunit/UnixDynamicLibraryManager.cpp \
	$(CPPUNIT_DIR)/src/cppunit/ShlDynamicLibraryManager.cpp \
	$(CPPUNIT_DIR)/src/cppunit/XmlDocument.cpp \
	$(CPPUNIT_DIR)/src/cppunit/XmlElement.cpp \
	$(CPPUNIT_DIR)/src/cppunit/XmlOutputter.cpp \
	$(CPPUNIT_DIR)/src/cppunit/XmlOutputterHook.cpp \
	$(CPPUNIT_DIR)/src/cppunit/Win32DynamicLibraryManager.cpp
  	
LOCAL_EXPORT_C_INCLUDES := $(CPPUNIT_DIR)/include
LOCAL_CPPFLAGS := -fpermissive  -funwind-tables
include $(BUILD_STATIC_LIBRARY)

include $(CLEAR_VARS)
LOCAL_C_INCLUDES := $(TOP)/include $(TOP)/source/include \
	$(TOP)/source/stdsdk \
	$(TOP)/source/stdsdk/include \
	$(TOP)/source/pullsdk \
	$(TOP)/source/pullsdk/include \
	$(TOP)/thirdparty/tutk/include \
	$(TOP)/source/plugin \
	$(CPPUNIT_DIR)/include
	
LOCAL_MODULE    := udktestsuite
LOCAL_CPPFLAGS := -fsigned-char -fpermissive -DCOMM_MODULE_AUTOINSTALL=1
LOCAL_LDLIBS := -llog -landroid  
LOCAL_SHARED_LIBRARIES:=udk
LOCAL_STATIC_LIBRARIES:=cppunit
LOCAL_SRC_FILES := \
	$(wildcard $(TOP)/test/*.cpp) 
LOCAL_ALLOW_UNDEFINED_SYMBOLS := false	
include $(BUILD_EXECUTABLE)


# Build a separate pullsdk library
include $(CLEAR_VARS)
LOCAL_C_INCLUDES := $(TOP)/include $(TOP)/source/include \
	$(TOP)/source/pullsdk \
	$(TOP)/source/pullsdk/include \
	$(TOP)/thirdparty/tutk/include \
	$(TOP)/source/plugin

LOCAL_CPPFLAGS := -fsigned-char -fpermissive -DCOMM_MODULE_AUTOINSTALL=1
LOCAL_LDLIBS := -llog -landroid

ENABLE_BLUETOOTH=1

LOCAL_SRC_FILES := \
	pull_jni.cpp \
	$(TOP)/source/pd/android/udk_os.cpp \
	$(TOP)/source/pd/android/ActiveSocket.cpp \
	$(TOP)/source/pd/android/PassiveSocket.cpp \
	$(TOP)/source/pd/android/pd_android.cpp \
	$(TOP)/source/pd/android/pthreadevent.cpp \
	$(wildcard $(TOP)/source/common/*.cpp) \
	$(wildcard $(TOP)/source/pullsdk/*.cpp) \
	$(TOP)/source/plugin/commtcp.cpp \
	$(TOP)/source/plugin/commudp.cpp 

ifeq ($(ENABLE_BLUETOOTH), 1)
	LOCAL_SRC_FILES += $(TOP)/source/plugin/commbt.cpp \
					$(TOP)/source/pd/android/bluetooth.cpp
	LOCAL_CPPFLAGS += -DENABLE_BLUETOOTH -DZKBIOLOCK
endif


LOCAL_PRELINK_MODULE := false
#LOCAL_SHARED_LIBRARIES:= fpsensor_commpro
LOCAL_MODULE    := pullSDK
LOCAL_ALLOW_UNDEFINED_SYMBOLS := false	
include $(BUILD_SHARED_LIBRARY)
